﻿using System;
using System.Collections.Generic;
using FlatRedBall;
using FlatRedBall.Input;
using FlatRedBall.Graphics;
using FlatRedBall.Gui;
using FlatRedBall.Math.Geometry;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using BulletHellBoxes.Utilities;
using BulletHellBoxes.Entities.Menu;

namespace BulletHellBoxes.Screens
{
    public class ControlScreen : Screen
    {
        private Sprite background;
        private MenuButton mainMenuButton;
        #region Methods

        #region Constructor and Initialize

        public ControlScreen()
            : base("MenuScreen")
        {
            // Don't put initialization code here, do it in
            // the Initialize method below
            //   |   |   |   |   |   |   |   |   |   |   |
            //   |   |   |   |   |   |   |   |   |   |   |
            //   V   V   V   V   V   V   V   V   V   V   V
            //Initialize(true);
        }

        public override void Initialize(bool addToManagers)
        {
            if (addToManagers)
            {
                AddToManagers();
            }
        }

        public override void AddToManagers()
        {
            // Set the screen up here instead of in the Constructor to avoid
            // exceptions occurring during the constructor.
            FlatRedBallServices.IsWindowsCursorVisible = true;

            // Initialize the sprites
            // Initialize background sprite
            background = SpriteManager.AddSprite(@"Content/Menu/Controls");
            background.PixelScale();
            this.mSprites.Add(background);

            mainMenuButton = new MenuButton("Global", @"Content/Menu/MainMenuButton", "", 'e', 19, -13);


        }
        #endregion

        #region Public Methods

        public override void Activity(bool firstTimeCalled)
        {
            checkCollisions();
        }

        public override void Destroy()
        {
            base.Destroy();
            mainMenuButton.Destroy();
            SpriteManager.RemoveSprite(background);

        }

        private void checkCollisions()
        {
            // Mouse collision check
            // Is Mouse on any button?
            if (InputManager.Mouse.IsOn(mainMenuButton.collision))
            {
                mainMenuButton.Hover();
                if (InputManager.Mouse.ButtonPushed(FlatRedBall.Input.Mouse.MouseButtons.LeftButton))
                {
                    Destroy();
                    MoveToScreen(typeof(MenuScreen).FullName);
                }
            }
            else
                mainMenuButton.Idle();
        }
        #endregion

        #endregion
    }
}
